#ifndef __FSMAI_H__
#define __FSMAI_H__

#include "FsmAIDef.h"
#include "FsmAIState.h"
#include <memory>

class FsmAILogic;
class FsmAIState;

class FsmAI
{
protected:
    FSM_AI_STATE m_EState;
    FsmAILogic*  m_Logics[AI_LOGIC_MAX-1];
public:
    FsmAI(/* args */) {
        m_EState = FSM_AI_STATE::AI_IDLE;
        memset(m_Logics, 0, sizeof(m_Logics));
    };
    ~FsmAI() {};
    FSM_AI_STATE getState() {return m_EState;};
    VOID changeState(FSM_AI_STATE state) {
        FsmAIState* oldState = FsmAIStateCache::getState(m_EState);
        FsmAIState* newState = FsmAIStateCache::getState(state);
        oldState->leave(this);
        m_EState = state;
        newState->enter(this);
    }

    VOID addLogic(FsmAILogic* p);
    FsmAILogic* getLogic(FSM_AI_LOGIC logicID) {
        return m_Logics[logicID];
    }
    bool hasLogic(FSM_AI_LOGIC logicID) {
        return m_Logics[logicID] != 0;
    }
};

class FsmAIMonster : public FsmAI {
public:
    FsmAIMonster() {};
    ~FsmAIMonster() {};
};


#endif